<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="<?php echo $this->_webroot('skin/css/admin.css'); ?>">
<link rel="stylesheet" type="text/css" href="<?php echo $this->_webroot('skin/css/main.css'); ?>">
<script type="text/javascript" src="<?php echo $this->_webroot('servtools/ajax_client/ajax.js'); ?>"></script>
<style>
td span {color:red;}
</style>
</head>
<body>
<div id="maincontent">
<psp:tags     htmlname='messagebox'  iconname='messagebox' />
	<div class="wrap">
	<div class="crumbs">当前位置 &gt;&gt; 商品管理 &gt;&gt; 修改分类</div>
        <hr />
	<div class="infobox">
	<h3><span class="left">修改分类 </span><span style="margin-right:15px;" class="right"><a style="float:right;" href="<?php echo $this->_url('admin/goods/categorieslist');?>">商品分类列表</a></span></h3>
    <div class="content2">
		<form action="<?php echo $this->_url('admin/goods/categoriesedit/'.$info['id']);?>" method="post" onsubmit="return checkform();" enctype="multipart/form-data">
		<table class="form-table">
		  <tbody>
			<tr>
				<td width="60px;">上级分类：</td>
				<td>
				<select name="data[goodscategories][parent_id]" onchange="getbrandlist(this.value);">
				<option value="0">顶级分类</option>
				<?php foreach($category_dg as $value) {?>
				<option value="<?php echo $value['id'];?>" <?php if($value['id']==$info['parent_id']) echo "selected";?> ><?php echo $value['str_pad'];?><?php echo $value['cat_name'];?></option>
				<?php }?>
				</select></td>
			</tr>
			<tr>
				<td>分类名称：</td>
				<td><input class="small-text" type="text" name="data[goodscategories][cat_name]" value="<?php echo $info['cat_name']; ?>" /> <span>*</span></td>
			</tr>
			<tr>
				<td>分类简介：</td>
				<td><input class="small-text" type="text" name="data[goodscategories][content]" value="<?php echo $info['content']; ?>" /> <span>*</span></td>
			</tr>			
			<tr>
				<td>分类排序：</td>
				<td><input class="small-text" type="text" name="data[goodscategories][sort_order]" value="<?php echo $info['sort_order']; ?>" style="width:60px" /> <span>*</span></td>
			</tr>
			<tr>
				<td>关联品牌:</td>
				<td>
					<select name="data[brand][][brand_id]" id="brand_id" multiple style="width:190px; height:300px;  overflow:auto;">
						<?php
							if (is_array($brand_list)) {
								foreach ($brand_list as $value){
						?>
						<option value="<?php echo $value['brand']['id'];?>"<?php if(in_array($value['brand']['id'],$category_brand_list)){echo "selected";}?>><?php echo $value['brand']['brand_name'];?></option>
						<?php
								}
							}
						?>
					</select>
				</td>
			</tr>
			<tr>
				<td colspan="2">
				<input type="hidden" name="data[goodscategories][id]" value="<?php echo $info['id']; ?>">
				<span class="button-container"><input class="regular-button" type="submit" name="submit" value="添加分类" /></span>
				</td>
			</tr>
		  </tbody>
		</table>
		</form>
	  </div>
	 </div>
	</div>
</div>
<script>
function checkform() {
	var cat_name = document.getElementsByName('cat_name')[0];
	if(cat_name.value=='') {
		ShowMessageBox("分类名称不能为空！",'0');
		return false;
	}
	return true;
}
function getbrandlist(idvalue){
	ajax("<?php echo $this->_url('admin/goods/getcatbrandlist');?>","POST","cat_id="+idvalue,function(data){
			var obj = document.getElementById('brand_id');
			for(i=0;i<obj.length;i++){
				for(j=0;j<data.length;j++){
					var obj2 = data[j];
					if(obj[i].value==obj2.b.brand_id){
						obj[i].selected=true;
					}
				}
			}
		},'json');
}
</script>
</body>
</html>